﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ASPItalia.ModelVirtualCasting.Web.Tests.Utils;
using ASPItalia.ModelVirtualCasting.ObjectModel;
using System.ComponentModel.DataAnnotations;

namespace ASPItalia.ModelVirtualCasting.Web.Tests.Models
{
    [TestClass]
    public class CandidateTests
    {
        [TestMethod]
        public void Candidate_FirstName_IsRequired_ByValidation()
        {
            // Arrange
            Candidate c = new Candidate();

            // Act
            var result = ModelTestHelper.ValidateModel(c);

            // Assert
            Assert.IsTrue(result.ContainsKey(() => c.FirstName));

            // Siamo confidenti???
        }

        [TestMethod]
        public void Candidate_FirstName_IsRequired()
        {
            // Act
            var result = ModelTestHelper.GetValidationAttributes<Candidate>(c => c.FirstName);
            
            // Assert
            Assert.IsTrue(result.Contains<RequiredAttribute>());
            Assert.IsTrue(result.Contains<StringLengthAttribute>());
            Assert.AreEqual(50, result.GetAttribute<StringLengthAttribute>().MaximumLength);
        }

    }
}
